<script setup lang="ts">
import { getMedicineOrderDetailApi } from "@/services/consult";
import type { ConsultOrderItem } from "@/types/consult";
import type { OrderDetail } from "@/types/order";
import { onMounted, ref } from "vue";
import { useRoute, useRouter } from "vue-router";

const route = useRoute();
const router = useRouter();
const orderDetail = ref<OrderDetail>();
async function getOrderDetail() {
  const res = await getMedicineOrderDetailApi(route.query.orderId as string);
  orderDetail.value = res.data;
}

onMounted(() => {
  getOrderDetail();
});
</script>

<template>
  <div class="orderPayResult-page">
    <cp-nav-bar title="药品支付结果"></cp-nav-bar>
    <div class="box">
      <div class="box1" v-if="orderDetail">
        <div class="money">
          <van-icon name="checked" color="#16c2a3" size="60" />
          <p>￥{{ orderDetail?.actualPayment }}</p>
          <p>订单支付成功，已通知药房尽快发出， 请耐心等待~</p>
        </div>
        <div class="btn">
          <van-button
            type="primary"
            @click="router.push('/orderDetail?orderId=' + orderDetail.id)"
            >查看订单</van-button
          >
          <van-button
            type="default"
            @click="router.push('/room?orderId=' + orderDetail.roomId)"
            >返回诊室</van-button
          >
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.box {
  height: calc(100vh - 46px);
  display: flex;
  justify-content: center;
  margin-top: 100px;
}
.money {
  width: 240px;
  text-align: center;
}
.btn {
  display: flex;
  justify-content: space-around;
  margin-top: 50px;
}
</style>
